package com.yang.knowledgebase.controller;

import com.yang.knowledgebase.dto.Result;
import com.yang.knowledgebase.pojo.Book;
import com.yang.knowledgebase.service.IBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/book")
public class BookController {
    @Autowired
    private IBookService bookService;

    @GetMapping("/all")
    public Result getAllBooks() {
        return bookService.getAllBook();
    }

    @GetMapping("/some/{bookName}")
    public Result getSomeBooks(@PathVariable("bookName") String bookName) {
        return bookService.getBooksByName(bookName);
    }
}
